﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SGRapidForm.Common;
using SGRapidForm.Foundation.Service.Interface;
using DevExpress.Web.ASPxMenu;
using System.Xml;
using SGRapidForm.Foundation.Entity;

namespace SGRapidForm.Foundation
{
    public partial class AreaMaintanceDetail : System.Web.UI.Page
    {
        private IFoundationService _foundationService = ServiceProxyFactory.Create<IFoundationService>("foundationservice");
        protected void Page_Load(object sender, EventArgs e)
        {
            JSManager.RegAjax(Header, this.GetType().BaseType);
        }

        /// <summary>
        /// 菜单项绑定事件 - 实现操作权限控制
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void menuHeader_ItemDataBound(object sender, MenuItemEventArgs e)
        {
            IHierarchyData itemHierarchyData = (IHierarchyData)e.Item.DataItem;
            XmlElement element = (XmlElement)itemHierarchyData.Item;
        }
        /// <summary>
        /// 新增保存
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        [AjaxPro.AjaxMethod]
        public bool SaveForAdd(AreaEntity area)
        {
            return _foundationService.AddArea(area);
        }

        /// <summary>
        /// 获取一条地区明细
        /// </summary>
        /// <param name="keyid">用地区Keyid</param>
        /// <returns></returns>
        [AjaxPro.AjaxMethod]
        public AreaEntity GetAreaByKeyid(string keyid)
        {

            return _foundationService.GetAreaByKeyid(keyid);
        }

        /// <summary>
        /// 编辑保存
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        [AjaxPro.AjaxMethod]
        public bool SaveForEdit(AreaEntity area)
        {
            return _foundationService.UpdateArea(area);
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="keyid">地区Keyid</param>
        /// <returns></returns>
        [AjaxPro.AjaxMethod]
        public bool Delete(string keyid)
        {
            return _foundationService.DeleteArea(keyid);
        }
    }
}